package com.qf.zyh.day64springboot.web.controller;

import com.qf.zyh.day64springboot.Day64SpringbootApplication;
import com.qf.zyh.day64springboot.entity.Emp;
import com.qf.zyh.day64springboot.services.EmpServices;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Collection;
import java.util.List;

@Controller
@RequestMapping("/emp")
public class EmpController{
    @Resource
    private EmpServices empServices;
    @RequestMapping("/getAll")
    public String geteeall(Model m, HttpSession session){
        List<Emp> all = empServices.getall();
        m.addAttribute("emplist",all);
        return "Index";
    }
    @RequestMapping("/login")
    public String login(String ename,String pwd){
        boolean i =empServices.login(ename,pwd);
        if (i) {
            return "redirect:/emp/getAll";
        }
        return "login";
    }
}
